import time
import traceback


def catch_except(func):
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except:
            with open('./error.log', 'a+') as f:
                error = traceback.format_exc()
                t = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
                content = "[{}]\n【入参】{}-{}\n【异常】{}\n".format(t, args, kwargs, error)
                f.write(content)
                print(content)

    return wrapper
